const quickSort = (list) => {
  if (list.length <= 1) return list

  const left = []
  const right = []
  const pivot = list.at(-1)
  for (let i = 0; i < list.length - 1; i++) {
    if (list[i] < pivot) left.push(list[i])
    if (list[i] > pivot) right.push(list[i]) 
  }
  return quickSort(left).concat([pivot], quickSort(right))
}

const arr = [1,4,3,6,5,8,7,2,9,0]
console.log(quickSort(arr));